#include <iostream>
#include <vector>
using namespace std;

//int Upstail(vector<int>& v, int count, int& sum)
//{
//    if (count >= v.size() - 1 )
//        return 0;
//
//    sum = Upstail(v, count + 1, sum) > Upstail(v, count + 2, sum) ? v[count + 1] + sum : v[count] + sum;
//    return sum;
//}

int main()
{
    vector<int> v;
    int n = 0;
    cin >> n;
    v.reserve(n);
    int num = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> num;
        v.push_back(num);
    }
    vector<int> min;
    min.reserve(v.size() + 1);
    min.push_back(0);
    min.push_back(0);
    for (int i = 2; i <= v.size(); i++)
    {
        int cost = (min[i - 2] + v[i - 2]) > (min[i - 1] + v[i - 1]) ? ((min[i - 1] + v[i - 1])) : (min[i - 2] + v[i - 2]);
        min.push_back(cost);
    }

    cout << min.back() << endl;
    return 0;
}